package org.example.DesignPatterns.Interpreter;

/**
 * @description:循环表达式
 * @author: farprt
 * @create: 2022-09-25 13:53
 **/
public class Repetition implements Expression {

    private int loopCount;
    private Expression loopBodySequence;//循环体内的子表达式序列

    public Repetition(Expression loopBodySequence,int loopCount ) {
        this.loopCount = loopCount;
        this.loopBodySequence = loopBodySequence;
    }

    @Override
    public void interpret() {
        while(loopCount>0){
            loopBodySequence.interpret();
            loopCount--;
        }
    }
}